from flask import Flask
from dotenv import load_dotenv
from appi.apps.config import Config
from flask import current_app

# 加载 .flaskenv 文件
load_dotenv()

config = Config()

from appi.apps.utils.creat_tables import *


data_session = sessionmaker(autoflush=False, autocommit=False, bind=engin)

from appi.apps.controller.user import user_controller




def get_app():
    app = Flask(__name__)
    app.config.from_object(config)
    with app.app_context():
        app.json.ensure_ascii = current_app.config['ENSURE_ASCII']
    app.register_blueprint(user_controller, url_prefix='/user')
    # 确保在应用上下文中创建数据库表

    return app